package com.liangzhong.model.match
{
	import flash.utils.ByteArray;

	/**
	 *比赛描叙：绝对状态（包括：中场开球、任意球、角球、边线球、点球） 
	 * @author lxh
	 * 
	 */	
	public class GameDes_Status
	{
		/**
		 *比赛id 
		 */	
		public var matchId		:int;
		
		public var time :int;
		public var ballX :Number;
		public var ballY :Number;
		public var list :Array = [];
		//json 标志
		public var gameDes_Status		:int = 1;
		
		public function GameDes_Status()
		{
		}
		/**
		 * 
		 * @param data
		 * 
		 */		
		public function readData(data : ByteArray):void
		{
			matchId = data.readUnsignedInt();
			time = data.readShort();
			ballX = data.readShort();
			ballY = data.readShort();
			var len :int = data.readShort();
			var i :int = 1;
			var playerStatus :PlayerStatus;
			while(i <= len)
			{
				playerStatus = new PlayerStatus();
				playerStatus.playerIndex = i;
				playerStatus.posX = data.readShort();
				playerStatus.posY = data.readShort();
				list.push(playerStatus);
				i ++;
			}
		}
		public function toString():String
		{
			return "{time:" + time + ",matchId:" + matchId + "ballX:" + ballX + "ballY:" + ballY + ",list:" + list + "}"
		}
		/**
		 *解析记录中数据
		 * @param obj
		 */		
		public function parseHistoryData(obj :Object):void
		{
			for(var str:String in obj)
			{
				if(this.hasOwnProperty(str))
				{
					this[str] = obj[str];
				}
			}
			var tempList :Array = list;
			var playerStatus :PlayerStatus;
			var i :int = 1;
			list = [];
			for each(var lObj :Object in tempList)
			{
				playerStatus = new PlayerStatus();
				playerStatus.parseHistoryData(lObj);
				playerStatus.playerIndex = i;
				list.push(playerStatus);
			}
		}
	}
}